home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 21.zip / BS1 part 21 / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].7z / Professional Page v4.0 (1993)(Gold Disk)(Disk 1 of 4)[HD].adf / rexx.lzh / FindAndReplace.pprx < prev    next >
Text File  |  1993-01-28  |  2KB  |  78 lines

  1. /*
  2. @BFind And Replace  @P@ICopyright Gold Disk Inc., Jan, 1993
  3.  
  4. This Genie will search and replace across all articles in a document.
  5. */
  6. if ~show(l, "gdarexxsupport.library") then
  7.    if ~addlib("gdarexxsupport.library", 0, -30) then
  8.    do
  9.       call ppm_Inform(1, "Please install the gdarexxsupport.library in your libs: directory before running this Genie.")
  10.       exit
  11.    end
  12.  
  13. cr = '0a'x
  14.  
  15. address command
  16. call SafeEndEdit.rexx()
  17. call ppm_AutoUpdate(0)
  18.  
  19. oldsearch = getclip(ppuser_search)
  20. oldreplace = getclip(ppuser_replace)
  21.  
  22. form = ppm_GetForm("Enter Search String..", 50, "Search for:"oldsearch ||cr"Replace with:"oldreplace)
  23.  
  24. if form = '' then exit_msg()
  25.  
  26. parse var form search '0a'x replace
  27.  
  28. if search = '' then exit_msg("Search string required")
  29.  
  30. case  = ppm_Inform(2, "Case sensitive?", "No","Yes")
  31.  
  32. call setclip(ppuser_search, search)
  33. call setclip(ppuser_replace, replace)
  34.  
  35. box = ppm_DocFirstBox()
  36. call ppm_ShowStatus("Working..")
  37.  
  38. ud = (randu() * time(s)) % 1
  39.  
  40. do while box ~= 0
  41.  
  42.    if upper(word(ppm_GetBoxInfo(box), 1)) = 'TEXT' & ppm_GetBoxUserData(box) ~= ud then
  43.    do
  44.                 oldbox = box
  45.  
  46.                 box = ppm_ArtFirstBox(box)
  47.          boxtext = ppm_GetArticleText(box, 1)
  48.  
  49.                  /*     replace string is called from the gdarexxsupport.library        */
  50.          boxtext = replacestring(boxtext, search, replace, case)
  51.          call ppm_DeleteContents(box)
  52.                  call ppm_TextIntobox(box, boxtext)
  53.  
  54.                  do while box ~= 0
  55.                         call ppm_SetBoxUserData(box, ud)
  56.                         box = ppm_ArtNextBox(box)
  57.                 end
  58.  
  59.                 box = oldbox
  60.    end
  61.  
  62.    box = DocNextbox(box)
  63.  
  64. end
  65.  
  66. exit_msg("Done!!")
  67.  
  68. exit_msg: procedure expose
  69. do
  70.         parse arg message
  71.  
  72.         if message ~= '' then call ppm_Inform(1, message,)
  73.         call ppm_ClearStatus()
  74.         call ppm_AutoUpdate(1)
  75.         exit
  76. end
  77.  
  78.